package org.lboot.flow.module.assign;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.Hibernate;
import org.lboot.jpa.entity.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * @TODO 支持flowModel 定义默认指派 -> SQL 优先于默认指派（覆盖）
 * @author kindear
 * 流程任务分配
 * 支持 普通 TASK 和 决策 TASK
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "flow_task_assign")
@ApiModel(value = "流程任务分配实例")
public class FlowTaskAssign extends BaseEntity implements Serializable {

    /**
     * 流程定义编码
     */
    @ApiModelProperty("流程定义编码")
    @Column(name = "flow_code")
    String flowCode;

    /**
     * 对应流程节点ID
     */
    @ApiModelProperty("流程节点ID")
    @Column(name = "flow_node_id")
    String flowNodeId;

    /**
     * 指派对象
     */

    @ApiModelProperty(value = "指派对象",notes = "DEPT / ROLE / USER / SELF")
    @Column(name = "assign_type")
    String assignType;

    /**
     * 指派对象ID
     */
    @ApiModelProperty("指派对象ID")
    @Column(name = "assign_id")
    String assignId;


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        FlowTaskAssign that = (FlowTaskAssign) o;
        return id != null && Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
